/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.psdk.local;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
import com.qihoo.psdk.f;
import com.qihoo.psdk.i;
import com.qihoo.psdk.k;
import com.qihoo.psdk.n;
import com.qihoo.psdk.util.d;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;

public class QLocalReceiver extends BroadcastReceiver {
    private static long a = 0L;

    public void onReceive(Context paramContext, Intent paramIntent) {
        try {
            String str1 = paramIntent.getAction();
            Bundle localBundle = paramIntent.getExtras();
            com.qihoo.psdk.util.h.a("QLocalReceiver", "action: " + str1);
            Object localObject2;
            String str4;
            if ("com.qihoo.psdk.action.notify".equals(str1)) {
                str2 = localBundle.getString("targetPack");
                com.qihoo.psdk.util.h.a("QLocalReceiver", "Notify targetPack: " + str2);
                if (!(paramContext.getPackageName().equals(str2)))
                    return;
                str3 = localBundle.getString("payload");
                com.qihoo.psdk.util.h.a("QLocalReceiver", "Encode payload: " + str3);
                str3 = com.qihoo.psdk.util.a.b(str3);
                com.qihoo.psdk.util.h.a("QLocalReceiver", "Decode payload: " + str3);
                localObject1 = new g(str3);
                if (!(((g) localObject1).a()))
                    return;
                if (("notification".equals(((g) localObject1).a)) && (((n.r(paramContext)) || (((g) localObject1).o)))) {
                    h.a(paramContext, (g) localObject1, str3);
                    return;
                }
                if (("alert".equals(((g) localObject1).a)) && (((n.r(paramContext)) || (((g) localObject1).o)))) {
                    d.a(paramContext, (g) localObject1, str3);
                    return;
                }
                if (!("message".equals(((g) localObject1).a)))
                    return;
                localObject2 = new Intent();
                ((Intent) localObject2).setAction("com.qihoo.psdk.app.msg");
                ((Intent) localObject2).putExtra("payload", ((g) localObject1).b);
                ((Intent) localObject2).setPackage(paramContext.getPackageName());
                paramContext.sendBroadcast((Intent) localObject2);
                str4 = com.qihoo.psdk.util.a.a(str3);
                HashMap localHashMap = new HashMap();
                localHashMap.put("msgId", str4);
                localHashMap.put("custom", "1");
                com.qihoo.psdk.a.a("arrived", localHashMap);
                return;
            }
            if (!("com.qihoo.psdk.action.local".equals(str1)))
                return;
            String str2 = localBundle.getString("type");
            String str3 = localBundle.getString("data");
            Object localObject1 = localBundle.getString("targetPack");
            com.qihoo.psdk.util.h.a("QLocalReceiver", "type: " + str2 + ", data: " + str3 + ", targetPack: "
                    + ((String) localObject1));
            if (!(paramContext.getPackageName().equals(localObject1)))
                return;
            if ("get_status".equals(str2)) {
                localObject2 = c.c();
                Toast.makeText(paramContext, (CharSequence) localObject2, 1).show();
                return;
            }
            if ("set_alias".equals(str2)) {
                f.a(str3);
                return;
            }
            if ("set_tags".equals(str2)) {
                f.b(str3);
                return;
            }
            if ("notify_click".equals(str2)) {
                localObject2 = new HashMap();
                ((HashMap) localObject2).put("msgId", str3);
                com.qihoo.psdk.a.a("click", (Map) localObject2);
                return;
            }
            if ("down_start".equals(str2)) {
                localObject2 = new HashMap();
                ((HashMap) localObject2).put("msgId", str3);
                com.qihoo.psdk.a.a("downstart", (Map) localObject2);
                return;
            }
            if ("down_finish".equals(str2)) {
                localObject2 = new HashMap();
                ((HashMap) localObject2).put("msgId", str3);
                com.qihoo.psdk.a.a("downfinish", (Map) localObject2);
                str4 = localBundle.getString("appPackName");
                int i = localBundle.getInt("appVersionCode");
                a locala = null;
                Boolean localBoolean = Boolean.valueOf(false);
                for (int j = 0; j < k.c.size(); ++j) {
                    locala = (a) k.c.get(j);
                    if (!(locala.d.equals(str4)))
                        continue;
                    localBoolean = Boolean.valueOf(true);
                    break;
                }
                if (localBoolean.booleanValue())
                    return;
                locala = new a();
                locala.i = str3;
                locala.d = str4;
                locala.e = i;
                k.c.add(locala);
                return;
            }
            if (!("app_start".equals(str2)))
                return;
            long l = new Date().getTime();
            if (l - a <= 1800000L)
                return;
            a = l;
            i.a(new com.qihoo.psdk.c("start", null));
        } catch (Exception localException) {
            com.qihoo.psdk.util.h.a("QLocalReceiver", localException);
        } catch (Error localError) {
            com.qihoo.psdk.util.h.a("QLocalReceiver", localError);
        }
    }
}